<template>
    <el-upload
        class="inventory-upload-wrap"
        :action="GLOBAL.urlRoot+ GLOBAL.szLocalInventory + '/localShenZhenInventoryHandler/uploadShenZhenLocalInventoryFile'"
        :on-success="onSuccess"
        :on-error="uploadError"
        :on-progress="onProgress"
        accept=".xlsx"
    >
        <el-button
            size="small"
            type="success"
            :disabled="Loading"
            :icon="Loading?'el-icon-loading':'el-icon-upload2'"
        >上传XLSX文件</el-button>
    </el-upload>
</template>
<script>
const ERR_OK = 200;
export default {
    data() {
        return {
            Loading: false
        };
    },
    created() {},
    methods: {
        onSuccess(onRes) {
            if (onRes.code === ERR_OK) {
                this.$ajax
                    .get(
                        this.GLOBAL.szLocalInventory +
                            "/localShenZhenInventoryHandler/generateShenZhenLocalInventoryTempTable"
                    )
                    .then(res => {
                        if (res.data.code === ERR_OK) {
                            this.$message.success("上传成功");
                        } else {
                            this.$message.error(res.data.msg);
                        }
                        this.Loading = false;
                    });
            } else {
                this.$message.error(onRes.msg);
                this.Loading = false;
            }
            this.updLoading = false;
        },
        uploadError(err, file, fileList) {
            this.$message.error("上传出错,请重新上传----" + err);
            this.Loading = false;
        },
        onProgress(err, file, fileList) {
            this.Loading = true;
        }
    }
};
</script>
<style lang="stylus">
.inventory-upload-wrap {
    display: inline-block;

    .el-upload-list {
        display: none;
    }
}
</style>